import count from "./js/count";
import sum from "./js/sum";
// 引入 Css 资源，Webpack才会对其打包
import "./css/index.css";
// 引入图标资源，Webpack才会对其打包
import "./css/iconfont.css";

import "core-js/es/promise";

// 添加promise代码
// const promise = Promise.resolve();
// promise.then(() => {
//   console.log("hello promise");
// });

// var result = '你好';检查eslint的功能
console.log(count(2,3));
console.log(sum(1,2,3,10))

// 判断是否支持HMR功能,热模块替换，提升打包速度
if (module.hot) {
    module.hot.accept("./js/count.js", function (count) {
      const result1 = count(21, 11);
      console.log(result1);
    });
  
    module.hot.accept("./js/sum.js", function (sum) {
      const result2 = sum(1, 2, 3, 4);
      console.log(result2);
    });
}

if ("serviceWorker" in navigator) {
    window.addEventListener("load", () => {
        navigator.serviceWorker
        .register("/service-worker.js")
        .then((registration) => {
            console.log("SW registered: ", registration);
        })
        .catch((registrationError) => {
            console.log("SW registration failed: ", registrationError);
        });
    });
}